package org.akomantoso.core.test.validator;

import java.text.DateFormat;
import java.text.SimpleDateFormat;

import junit.framework.Assert;

import org.akomantoso.core.data.FRBRauthor;
import org.akomantoso.core.data.FRBRcountry;
import org.akomantoso.core.data.FRBRdate;
import org.akomantoso.core.data.FRBRlanguage;
import org.akomantoso.core.data.FRBRthis;
import org.akomantoso.core.data.FRBRuri;


/**
 * @author <a href="mailto:jacques.militello@gmail.com">Jacques Militello</a>
 */
public final class Validator {

	public static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
	
	private Validator() {
	}
	
	public static void assertFRBRthis(FRBRthis frbrThis,String value,String id,String evolvingId) {
		Assert.assertEquals("FRBRthis : [value] incorrect", value, frbrThis.getValue());
		Assert.assertEquals("FRBRthis : [id] incorrect", id, frbrThis.getId());
		Assert.assertEquals("FRBRthis : [elvovingId] incorrect", evolvingId, frbrThis.getEvolvingId());
	}
	
	public static void assertFRBRuri(FRBRuri uri,String value,String id,String evolvingId) {
		Assert.assertEquals("FRBRuri : [value] incorrect", value,uri.getValue());
		Assert.assertEquals("FRBRuri : [id] incorrect", id, uri.getId());
		Assert.assertEquals("FRBRuri : [elvovingId] incorrect", evolvingId, uri.getEvolvingId());
	}
	
	public static void assertFRBRdate(FRBRdate date,String dateValue,String name,String id,String evolvingId) {
		Assert.assertEquals("FRBRdate : [date] incorrect", dateValue,DATE_FORMAT.format(date.getDate().getTime()));
		Assert.assertEquals("FRBRdate : [name] incorrect", name,date.getName());
		Assert.assertEquals("FRBRdate : [id] incorrect", id,date.getId());
		Assert.assertEquals("FRBRdate : [elvovingId] incorrect", evolvingId,date.getEvolvingId());
	}
	
	public static void assertFRBRauthor(FRBRauthor author,String href,String as,String id,String evolvingId) {
		Assert.assertEquals("FRBRauthor : [href] incorrect", href,author.getHref());
		Assert.assertEquals("FRBRauthor : [as] incorrect", as,author.getAs());
		Assert.assertEquals("FRBRauthor : [id] incorrect", id,author.getId());
		Assert.assertEquals("FRBRauthor : [elvovingId] incorrect", evolvingId,author.getEvolvingId());
	}
	
	public static void assertFRBRcountry(FRBRcountry country,String value,String id,String evolvingId) {
		Assert.assertEquals("FRBRcountry : [value] incorrect", value,country.getValue());
		Assert.assertEquals("FRBRcountry : [id] incorrect", id, country.getId());
		Assert.assertEquals("FRBRcountry : [elvovingId] incorrect", evolvingId, country.getEvolvingId());
	}
	
	public static void assertFRBRlanguage(FRBRlanguage language,String value,String id,String evolvingId) {
		Assert.assertEquals("FRBRlanguage : [language] incorrect", value,language.getLanguage());
		Assert.assertEquals("FRBRlanguage : [id] incorrect", id, language.getId());
		Assert.assertEquals("FRBRlanguage : [elvovingId] incorrect", evolvingId, language.getEvolvingId());
	}
	
}
